﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Vote
{
    public class Operation
    {
        /// <summary>
        /// 投票
        /// </summary>
        /// <param name="Questions"></param>
        /// <param name="Voter"></param>
        public void Voting(List < Question > Questions,User Voter)
        {
            
            for(int count = 0; count < Questions.Count; count++)
            {
                
                Console.WriteLine(Questions[count].Content);
                if (Questions[count].PastDue() == 1)
                {
                    for(int amount = 0; amount < Questions[count].questionOptions.Count;amount++)
                    {
                        Console.WriteLine(amount+":"+Questions[count].questionOptions[amount].Content);
                    }
                    Console.WriteLine("请输入你选择的选项");
                    int QuestionSelect=int.Parse(Console.ReadLine());
                    Questions[count].questionOptions[QuestionSelect].Voting(Voter);
                    
                }
            }

        }
        /// <summary>
        /// 查看投票统计
        /// </summary>
        public void Examine(List<Question> Questions)
        {
            for (int count = 0; count < Questions.Count; count++)
            {
                Console.WriteLine(Questions[count].Content);
                if (Questions[count].PastDue() == 1)
                {
                    for (int amount = 0; amount < Questions[count].questionOptions.Count; amount++)
                    {
                        Console.WriteLine(amount + ":" + Questions[count].questionOptions[amount].Content + "    "+Questions[count].questionOptions[amount].poll+"票");
                    }

                }
            }
        }
    }
}
